$(document).ready(function(){
	var cust_class = $('#cust_class').val();
	checkCustClass(cust_class)
});

function checkCustClass(val) {

	$.ajax({
   type: "POST",
   url: "/program/admin/custclass/checkCustClass.jsp",
   data: "cust_class="+val,
   success: function(response){
     $('#hiddenCustData').html(response);
	 if($('#checkCustDataRemote').text() == "1"){
		$('#alertCheckMessage').css('display','');
	 }else{
		$('#alertCheckMessage').css('display','none');
	 }
   }
 });
}

function submitForm() {
	var str = document.getElementById("cust_class").value;
	var res = str.search(/^\d+(\.\d+)?$/) ;
	if(res == -1)  {
	alert("级别编号不能为空!");
	document.getElementById('cust_class').focus();
		return false;
	}
	//fixed by Zhouxq
	if(str==''){
		alert('级别编号不能为空');
		document.getElementById('cust_class_name').focus();
		return false;
	}
	
	if(document.getElementById('cust_class_name').value==''){
		alert('级别名称不能为空');
		document.getElementById('cust_class_name').focus();
		return false;
	}
	if($('#checkCustDataRemote').text() == "1"){
	alert("级别编号已存在，请重新输入!");
	document.getElementById('cust_class').focus();
	return false;
	}
	
	document.addForm.submit();
}

